//GLOBAL VARS

var pageHeight;
var pageWidth;

//FUNCTIONS

var width_variable = function() {
    if (document.documentElement.clientWidth < window.innerWidth) {
        pageWidth = window.innerWidth;
    }
    else {
        pageWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    };
};

var height_variable = function() {
    if (document.documentElement.clientHeight < window.innerHeight) {
        pageHeight = window.innerHeight;
    }
    else {
        pageHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    };
};


var pngFallback = function() {
    if (!Modernizr.svg) {
        var imgs = document.getElementsByTagName('img');
        var svgExtension = /.*\.svg$/
        var l = imgs.length;
        for(var i = 0; i < l; i++) {
            if(imgs[i].src.match(svgExtension)) {
                imgs[i].src = imgs[i].src.slice(0, -3) + 'png';
            }
        }
    }
};

var equalHeight = function() {
    $('#my-work a').each(function(){
        $(this).height($(this).width());
    });
};


var heroHeight = function() {
    $('.header-spacer, .header-wrapper, #big-video-vid').height(pageHeight + 'px');
};


/*var fullScreenResize = function() {
    //$('.header-spacer, .full-width-container, .header-wrapper').height($('.fp-tableCell').height());
};*/

/*var scrollLoad = function() {
    $('body').click();
};*/

//INIT

$(document).ready(function(){
    width_variable();
    height_variable();
    
    heroHeight();
    
    $('a[href*="#"]').each(function() {
        $(this).click(function(){
            $('html, body').animate({
                scrollTop: ($( $.attr(this, 'href') ).offset().top) - $('.full-width-container.navbar').height()
            }, 1000, "swing");
            return false;
        });

    });
   
    pngFallback();   
});

$(window).resize(function(){
    
    width_variable();
    height_variable();
    
    heroHeight();
    
    console.log($('.fp-tableCell').height());
});